package com.travelsmart.client.apresentacao.screen;

import java.util.List;


import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.TabPanel;
import com.travelsmart.client.apresentacao.controller.Observer;
import com.travelsmart.client.apresentacao.view.ViewDadosHotel;
import com.travelsmart.client.apresentacao.view.ViewListaHotel;
import com.travelsmart.client.apresentacao.view.ViewCriaReservaHotel;
import com.travelsmart.client.apresentacao.view.ViewPesquisaHotel;
import com.travelsmart.client.bean.to.HotelTO;
import com.travelsmart.client.bean.to.QuartoTO;


public class RealizarReservaHotelScreen extends BaseScreen implements Observer{

	//
	
	//
	public TabPanel panelScreenHotel = new TabPanel();

	public RealizarReservaHotelScreen(ViewPesquisaHotel viewPesquisaHotel, ViewListaHotel viewListaHotel, 
			ViewDadosHotel viewDadosHotel, ViewCriaReservaHotel viewReservaHotel){
		super();
		// INICIO - EXERC. 3
		viewPesquisaHotel.setWidth("100%");
		viewPesquisaHotel.exec();
		this.panelScreenHotel.add(viewPesquisaHotel, viewPesquisaHotel.getNome());
		this.panelScreenHotel.add(viewListaHotel, viewListaHotel.getNome());
		this.panelScreenHotel.add(viewDadosHotel, viewDadosHotel.getNome());
		this.panelScreenHotel.add(viewReservaHotel, viewReservaHotel.getNome());
		this.panelScreenHotel.setWidth("100%");
		super.panelScreen.add(panelScreenHotel);
		exec();
		// FIM - EXERC. 3 # 
	}
	
	

	public void exec(){
		this.panelScreenHotel.selectTab(0);
	}

	@Override
	public void update(Object arg) {
		// INICIO - EXERC. 3
		if (arg instanceof List) {
			panelScreenHotel.selectTab(1);
		} else if (arg instanceof HotelTO) {
			panelScreenHotel.selectTab(2);
		} else if (arg instanceof QuartoTO) {
			panelScreenHotel.selectTab(3);
		} else if (arg instanceof RuntimeException) {
	
		} else if (arg instanceof String) {
			panelScreenHotel.selectTab(0);
		} else {
			assert false : "sem acao p/ " + arg.getClass().getName();
		}
		// FIM - EXERC. 3
		
	}

}
